<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>    

<script type="text/javascript" src="/${initParam.rootPath }/se/js/HuskyEZCreator.js" charset="UTF-8"></script>

<b>${requestScope.qnaBoard.code }번 글 수정</b><p/>
<form action="/${initParam.rootPath }/qna/modifyContent.do" method="post" onsubmit="return writeCheck(this);">
<input type='hidden' name="code" value="${requestScope.qnaBoard.code }">
<input type="hidden" name="hit" value="${requestScope.qnaBoard.hit }">
<input type="hidden" name="category" value="${requestScope.qnaBoard.category }">

<input type="hidden" name="page" value="${param.page }">

<table style="width:830px">
 <tr>
	<td width="100px">제목</td>
	<td><input type="text" name="title" maxlength="200" size="50" value="${requestScope.qnaBoard.title }"></td>
 </tr>
 <tr>
	<td>작성자</td>
	<td><input type="text" name="name" value="${sessionScope.login_info.id }" readonly="readonly"></td>
 </tr>
 <tr>
	<td colspan=2>
	<textarea cols="110" rows="20" name="contents" id="contents">
${requestScope.qnaBoard.contents }</textarea>
</td>
 </tr>
 <tr>
 	<td colspan="2" align="center">
	 	<input type="submit" value="수정">
	 	<input type="reset" value="초기화">
	 </td>
 </tr>
 </table>
 </form>

<script type="text/javascript">
var oEditors = [];

nhn.husky.EZCreator.createInIFrame({
	oAppRef: oEditors,
	elPlaceHolder: document.getElementById("contents"), 
	sSkinURI: "/${initParam.rootPath }/se/SmartEditor2Skin.html", 
	fOnAppLoad: function(){
		var contents = localStorage.getItem("contents");
		oEditors.getById["contents"].exec("PASTE_HTML", [contents]);
	}, 
	fCreator: "createSEditor2" 
});

function writeCheck(form) {

	if (!form.title.value) {
		alert("제목을 입력하세요.");
		form.title.focus();
		return false;
	}
	
	oEditors.getById["contents"].exec("UPDATE_CONTENTS_FIELD", []);

	var ch = document.getElementById("contents").value;
	if (!ch || ch == '<p>&nbsp;</p>') {
		alert("내용을 입력하세요.");
		oEditors.getById["contents"].exec("FOCUS", []);
		return false;
	} else {
		try {
			document.form.submit();
		} catch (e) {}
	}
	
};

var pasteHTML = function(){
	var sHTML = oEditors.getById["contents"].exec("PASTE_HTML", [sHTML]);
};
</script>
































